#include "StdAfx.h"
#include "SelectionOperator.h"
#include "QueueEntity.h"

SelectionOperator::SelectionOperator(void)
{
	
}


SelectionOperator::~SelectionOperator(void)
{
}


void SelectionOperator::execution(int executionTimes)
{
	
#ifdef DEBUG
	std::cout<<"===================operator begin================="<<std::endl;
	std::cout<<"operatorid : "<<this->getId()<<std::endl;
#endif
	assert(this->getInputQueueList().size()==1);
	assert(this->getOutputQueueList().size()==1);
	boost::shared_ptr<QueueEntity>inputQueue = this->getInputQueueList().front();
	boost::shared_ptr<QueueEntity>outputQueue = this->getOutputQueueList().front();
	for ( int i = 0 ; i < executionTimes ; i++) 
	{
		Element inputElement;
		if(outputQueue->isFull())
		{
			break;
		}
		if(inputQueue->isEmpty())
		{
			break;
		}
		inputQueue->dequeue(inputElement);
		if(true)
		{
			outputQueue->enqueue(inputElement);
		}

	}
#ifdef DEBUG
	std::cout<<"===================operator over================="<<std::endl;
#endif
}

void SelectionOperator::setSelectionCondition(std::string selectionCondition)
{
	this->selectionCondition = selectionCondition;
}